package br.unifor.cct.mia.ga.util;

import br.unifor.cct.mia.util.Methods;

public class FeatureConstructionOperators {

	public static String IGUAL = "=";
	public static String DIFERENTE = "!=";
	public static String MAIOR = ">";
	public static String MENOR = "<";
	public static String MAIOR_IGUAL = ">=";
	public static String MENOR_IGUAL = "<=";
	
	public static String getRandom() {
		int num = Methods.randIntValue(0,6);
		
		String result = IGUAL;
		switch (num) {
			case 0:
				result = IGUAL;
			break;		
			case 1:
				result = DIFERENTE;
			break;
			case 2:
				result = MAIOR;
			break;
			case 3:
				result = MENOR;
			break;
			case 4:
				result = MAIOR_IGUAL;
			break;
			case 5:
				result = MENOR_IGUAL;
			break;
		}
		return result;
	}
	
	public static int getValue(String s) {		
		
		int result = 0;
		
		if ( s.equalsIgnoreCase(IGUAL) ) result = 0;
		else if ( s.equalsIgnoreCase(DIFERENTE) ) result = 1;
		else if ( s.equalsIgnoreCase(MAIOR) ) result = 2;
		else if ( s.equalsIgnoreCase(MENOR) ) result = 3;
		else if ( s.equalsIgnoreCase(MAIOR_IGUAL) ) result = 4;
		else if ( s.equalsIgnoreCase(MENOR_IGUAL) ) result = 5;
		
		return result;
	}
	
	public static int getHash(int num) {		
		
		int result = 1;
		switch (num) {
			case 0:
				result *= 3;
			break;		
			case 1:
				result *= 5;
			break;
			case 2:
				result *= 7;
			break;
			case 3:
				result *= 11;
			break;
			case 4:
				result *= 13;
			break;
			case 5:
				result *= 17;
			break;
		}
		return result;
	}
}
